package com.example.neusoft215gdh.androidpro_21.Fragement;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioButton;
import android.widget.TextView;

import com.example.neusoft215gdh.androidpro_21.Activity.EditpersonActivity;
import com.example.neusoft215gdh.androidpro_21.Activity.GuanyuYuejianActivity;
import com.example.neusoft215gdh.androidpro_21.Activity.LoveActivity;
import com.example.neusoft215gdh.androidpro_21.Activity.MainActivity;
import com.example.neusoft215gdh.androidpro_21.Activity.OrderActivity;
import com.example.neusoft215gdh.androidpro_21.Activity.UpdatePsdActivity;
import com.example.neusoft215gdh.androidpro_21.JavaBean.MySelfBean;
import com.example.neusoft215gdh.androidpro_21.Listener.MyListener;
import com.example.neusoft215gdh.androidpro_21.Model.ActivityModel;
import com.example.neusoft215gdh.androidpro_21.R;

public class MySelfFragment extends Fragment   implements MyListener
{

//	声明
	private RadioButton myorder;
	private RadioButton myshaitu;
	private RadioButton myguanzhu;
	private TextView textView4;
	private TextView guanyuyuejian;
	private TextView edit_person;
//	private CircleImageView imageView_master;

	//   private MySelfBean MySelf;
	private int id;
	TextView password;
	private Intent intent;

	private View view=null;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
							 Bundle savedInstanceState)
	{
		view=inflater.inflate(R.layout.fragment_person, container, false);
		intent = new Intent();
		initView();
		eventCiclk();
		return  view;
	}

	public  void initView(){
		//初始化
		myorder = (RadioButton)view.findViewById(R.id.radio_peixun);
		myshaitu = (RadioButton)view.findViewById(R.id.radio_club);
		myguanzhu = (RadioButton)view.findViewById(R.id.radio_saitu);
		edit_person= (TextView) view.findViewById(R.id.edit_person);
		guanyuyuejian= (TextView) view.findViewById(R.id.guanyuyuejian);
		password= (TextView) view.findViewById(R.id.password);
	    textView4 = (TextView)view.findViewById(R.id.textView4);

		ActivityModel activityModel = new ActivityModel();
	    SharedPreferences  sharedPreferences=getActivity().getSharedPreferences("Userid", Context.MODE_PRIVATE);
		activityModel.userInfo(sharedPreferences.getString("user_id","1"),this);
	}

	private void eventCiclk(){
		myorder.setOnClickListener(new MyListener());
		myshaitu.setOnClickListener(new MyListener());
		myguanzhu.setOnClickListener(new MyListener());
		edit_person.setOnClickListener(new MyListener());
		guanyuyuejian.setOnClickListener(new MyListener());
		password.setOnClickListener(new MyListener());
	}
	@Override
	public void onResume(){
		super.onResume();

	}
	@Override
	public void onResponse(MySelfBean bean) {
//		Picasso.with(getActivity()).load("http://172.24.10.175/workout/Uploads/"+bean.getPhoto()).into(imageView_master);
		textView4.setText(bean.getTel());
	}

	@Override
	public void onFail(String msg) {

	}


	class MyListener implements View.OnClickListener{
		@Override
		public void onClick(View view) {
			switch (view.getId()){
				case R.id.radio_peixun:
					intent.setClass(getActivity(), MainActivity.class);
					startActivity(intent);
					break;
				case R.id.radio_club:
					intent.setClass(getActivity(), LoveActivity.class);
					startActivity(intent);
					break;
				case R.id.radio_saitu:
					intent.setClass(getActivity(), OrderActivity.class);
					startActivity(intent);
					break;
				case R.id.edit_person:
					intent.setClass(getActivity(), EditpersonActivity.class);
					startActivity(intent);
					break;
				case R.id.guanyuyuejian:
					intent.setClass(getActivity(), GuanyuYuejianActivity.class);
					startActivity(intent);
					break;
				case R.id.password:
					intent.setClass(getActivity(), UpdatePsdActivity.class);
					startActivity(intent);
			}
		}
	}
}
